package com.ruoyi.business.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.business.vo.CardBlacklistVo;
import com.ruoyi.business.service.ICardBlacklistService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.page.TableDataInfo;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

/**
 * 员工每日工作统计;Controller
 *
 * @author Tellsea
 * @date 2025-02-06
 */
@Api(tags = "员工每日工作统计;Controller")
@RestController
@RequestMapping("/business/blacklist")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class CardBlacklistController extends BaseController {

    private final ICardBlacklistService cardBlacklistService;

    @ApiOperation("查询员工每日工作统计;列表")
    @PreAuthorize("@ss.hasPermi('business:blacklist:list')")
    @GetMapping("/list")
    public TableDataInfo<CardBlacklistVo> list(CardBlacklistVo entity) {
        return cardBlacklistService.queryList(entity);
    }

    @ApiOperation("查询员工每日工作统计;所有列表")
    @GetMapping("/listAll")
    public AjaxResult listAll(CardBlacklistVo entity) {
        return AjaxResult.success("查询成功", cardBlacklistService.queryAll(entity));
    }

    @ApiOperation("导出员工每日工作统计;列表")
    @PreAuthorize("@ss.hasPermi('business:blacklist:export')")
    @Log(title = "员工每日工作统计;", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CardBlacklistVo entity) {
        List<CardBlacklistVo> list = cardBlacklistService.queryAll(entity);
        ExcelUtil<CardBlacklistVo> util = new ExcelUtil<>(CardBlacklistVo.class);
        util.exportExcel(response, list, "员工每日工作统计;数据");
    }

    @ApiOperation("获取员工每日工作统计;详细信息")
    @PreAuthorize("@ss.hasPermi('business:blacklist:query')")
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success("查询成功", cardBlacklistService.queryById(id));
    }

    @ApiOperation("新增员工每日工作统计;")
    @PreAuthorize("@ss.hasPermi('business:blacklist:add')")
    @Log(title = "员工每日工作统计;", businessType = BusinessType.INSERT)
    @PostMapping("add")
    public AjaxResult add(@RequestBody CardBlacklistVo entity) {
        return toAjax(cardBlacklistService.save(entity));
    }

    @ApiOperation("修改员工每日工作统计;")
    @PreAuthorize("@ss.hasPermi('business:blacklist:edit')")
    @Log(title = "员工每日工作统计;", businessType = BusinessType.UPDATE)
    @PostMapping("edit")
    public AjaxResult edit(@RequestBody CardBlacklistVo entity) {
        return toAjax(cardBlacklistService.updateById(entity));
    }

    @ApiOperation("删除员工每日工作统计;")
    @PreAuthorize("@ss.hasPermi('business:blacklist:remove')")
    @Log(title = "员工每日工作统计;", businessType = BusinessType.DELETE)
	@GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(cardBlacklistService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }

//	@ApiOperation("导入员工每日工作统计;")
//	@PreAuthorize("@ss.hasPermi('business:blacklist:remove')")
//	@Log(title = "员工每日工作统计;", businessType = BusinessType.DELETE)
//	@PostMapping("/upload")
//	public AjaxResult upload(@RequestParam("file") MultipartFile file) {
//		return cardBlacklistService.upload(file);
//	}


}
